package com.lc.ei.config.dynamiccomp;

import javax.tools.SimpleJavaFileObject;
import java.net.URI;

/**
 * @description: 用于动态生成实体
 * @author: LChuang
 * @date: 2023/9/19 9:07
 */
public class JavaSourceFromString extends SimpleJavaFileObject {

    /**
     * The source code of this "file".
     */
    final String code;

    public JavaSourceFromString(String name, String code) {
        super(URI.create("string:///" + name.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE);
        this.code = code;
    }

    @Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) {
        return code;
    }
}
